#include <stdio.h>
typedef long long ll;
int L, R;
ll ans;
int twos(int x) {
  int ret = 0;
  while(x) {
    if(x%10==2) ret++;
    x/=10;
  }
  return ret;
}
int main() {
  scanf("%d%d", &L, &R);
  for(int i=L; i<=R; ++i) ans += twos(i);
  printf("%lld\n", ans);
}

